package cn.ffcs.uec.outStaffAdjustPostApply.component;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zk.ui.Components;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.ForwardEvent;
import org.zkoss.zul.Bandbox;

import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaffAdjustPostApply.component.bean.OutStaffBandboxExtBean;

@Controller
@Scope("prototype")
public class OutStaffBandboxExt extends Bandbox implements IdSpace {
	
	private static final long serialVersionUID = 1068142474680016732L;
	/**
	 * 页面对应的bean
	 */
	private OutStaffBandboxExtBean bean = new OutStaffBandboxExtBean();

	/**
	 * 页面zul
	 */
	public static final String zul = "/pages_nmg/uec_outStaff/comp/outStaffInfoBandbox/outStaff_bandbox_ext.zul";
	
	private UecOutStaffInfo uecOutStaffInfo;
	
	private OutStaffListboxExt outStaffListboxExt;
	
	public OutStaffBandboxExt() {
		Executions.createComponents(zul, this, null);
		Components.wireVariables(this, bean);
		Components.addForwards(this, this, '$');
		
		// 1、先获取控件
		outStaffListboxExt = (OutStaffListboxExt)this.getFellow("outStaffListboxExt");
		// 2、中转：转换监听的事件与处理事件的方法名
		outStaffListboxExt.addForward("onSelectUecOutStaffInfo", this, "onSelectUecOutStaffInfoResponse");
	}
	
	/**
	 * 监听事件 OrganizationRelationListboxExt 中的listbox选中记录事件
	 * 
	 * @param event
	 */
	public void onSelectUecOutStaffInfoResponse(final ForwardEvent event) {
		uecOutStaffInfo = (UecOutStaffInfo) event.getOrigin().getData();
		if (null != uecOutStaffInfo) {
			setValue(uecOutStaffInfo.getPsnCode());
			this.close();
		}
		Events.postEvent("onUecOutStaffInfoEditSelected",this, uecOutStaffInfo);
	}
	
	/**
	 * 点击”确认“按钮事件
	 */
	public void onClick$okButton() {
		this.close();
	}

	/**
	 * 点击“取消”按钮事件
	 */
	public void onClick$cancelButton() {
		this.close();
	}

}
